-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix link version upgrade and enable it #205
Conversation
Please add comments and add some details in the description |
@@ -398,7 +398,7 @@ class BtreeNode : public sisl::ObjLifeCounter< BtreeNode > { | |||
return true; | |||
} | |||
|
|||
virtual BtreeLinkInfo get_edge_value() const { return BtreeLinkInfo{edge_id(), link_version()}; } | |||
virtual BtreeLinkInfo get_edge_value() const { return BtreeLinkInfo{edge_id(), edge_link_version()}; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
edge link version needed to chat instead of the node link version
child_info.set_bnode_id(edge_id); | ||
// If bsearch points to last index, it means the search has not found entry unless it is an edge value. | ||
if (!child_info.has_valid_bnode_id()) { | ||
if (!node->has_valid_edge()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: call has_valid_edge() instead of has_valid_bnode_id
BT_NODE_LOG_ASSERT(false, node, "Child index {} does not have valid bnode_id", index); | ||
return btree_status_t::not_found; | ||
} | ||
child_info = node->get_edge_value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to non-edge child (i.e., get_nth_value
in the else statement), both child id and link version need to be populated.
@@ -528,13 +528,14 @@ btree_status_t Btree< K, V >::merge_nodes(const BtreeNodePtr& parent_node, const | |||
// Finally update the leftmost node with latest key | |||
leftmost_node->set_next_bnode(next_node_id); | |||
if (leftmost_node->total_entries()) { | |||
// leftmost_node->inc_link_version(); | |||
leftmost_node->inc_link_version(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enable the the increase link version of left most node in merge
@@ -567,6 +568,28 @@ btree_status_t Btree< K, V >::merge_nodes(const BtreeNodePtr& parent_node, const | |||
#ifndef NDEBUG | |||
// BT_DBG_ASSERT(!parent_node_step1.empty() && !parent_node_step2.empty() && !parent_node_step3.empty(), | |||
// "Empty string"); | |||
// check if the link version of parent for each key info match the link version of its child | |||
BtreeLinkInfo child_info; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate the link version of updated parent keys and that of its children match
This pull request addresses an issue with link version inconsistency between a parent node and its children after a merge or split operation is performed. This change is necessary to ensure the stability and correctness of the btree during repair/recovery . This is achieved through the following changes:
get_edge_value()
method now returns the correct value for the edge's link version.inc_link_version
is now enabled in the merge and split methods.BT_NODE_DBG_ASSERT_EQ
check has been added to validate the change made during merge (split, as it has a trivial algorithm, does not need this validation).Overall, this pull request ensures that link version stays consistent between parent and children nodes, even after a merge or split operation is performed.